package game.Config;

import game.Actors.Tower;

import java.util.ArrayList;
import java.util.HashMap;

import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Vector2f;

import Weapons.FreezeGun;
import Weapons.Pistol;
import Weapons.RocketGun;
import Weapons.Weapon;

/**
 * This class represents the configuration of all the towers in the game.
 * 
 * @author Sebastian Isheden and Victor Beer
 *
 */
public class TowerConfig {
	public static final HashMap<TowerInfo,Tower> towerInfoMap = new HashMap<TowerInfo,Tower>();
	public static final ArrayList<TowerInfo> basicTowers = new ArrayList<TowerInfo>();
	private static final Vector2f zeroVector = new Vector2f(0,0);
	
	/**
	 * Initializes all the towers.
	 * @throws SlickException
	 */
	public static void initialize() throws SlickException {
		intializeBasicTowerSeries();
		intializeIceTowerSeries();
		initializeRocketTowerSeries();
	}
	private static Tower rocketTower;
	private static TowerInfo rocketTowerInfo;
	private static Image rocketTowerImage;
	//float fireRate, float damage, float bulletSpeed,float explosionRadius
	private static final Weapon ROCKET_TOWER_WEAPON = new RocketGun(0.5f,3,300,100);
	private static final String ROCKET_TOWER_DESCRIPTION = "This tower fires explosive rockets.";
	private static final float ROCKET_TOWER_RADIUS = 150;
	private static final float ROCKET_TOWER_COST = 400;
	
	private static Tower rocketTower2;
	private static TowerInfo rocketTower2Info;
	private static Image rocketTower2Image;
	private static final Weapon ROCKET_TOWER2_WEAPON = new RocketGun(0.5f,6,300,150);
	private static final String ROCKET_TOWER2_DESCRIPTION = "Gives the tower newer, bigger rockets!";
	private static final float ROCKET_TOWER2_RADIUS = 150;
	private static final float ROCKET_TOWER2_COST = 200;

	private static void initializeRocketTowerSeries() throws SlickException {
		rocketTowerImage = new Image("RocketTower.png");
		rocketTower2Image = rocketTowerImage.copy();
		
		rocketTowerInfo = new TowerInfo(rocketTowerImage.copy(),ROCKET_TOWER_DESCRIPTION,ROCKET_TOWER_RADIUS,ROCKET_TOWER_COST,Config.hudFont);
		rocketTower2Info = new TowerInfo(rocketTower2Image.copy(),ROCKET_TOWER2_DESCRIPTION,ROCKET_TOWER2_RADIUS,ROCKET_TOWER2_COST,Config.hudFont);
		
	    rocketTower = new Tower(rocketTowerImage.copy(),zeroVector.copy(),ROCKET_TOWER_WEAPON,ROCKET_TOWER_RADIUS,rocketTower2Info);
	    rocketTower.remove();
	    towerInfoMap.put(rocketTowerInfo, rocketTower);
	    basicTowers.add(rocketTowerInfo);
	    
	    rocketTower2 = new Tower(rocketTower2Image.copy(),zeroVector.copy(),ROCKET_TOWER2_WEAPON,ROCKET_TOWER2_RADIUS,null);
	    rocketTower2.remove();
	    towerInfoMap.put(rocketTower2Info, rocketTower2);
	    		
	}

	private static Tower iceTower;
	private static TowerInfo iceTowerInfo;
	private static Image iceTowerImage;
	//float fireRate, float damage, float bulletSpeed, float numBullets,float fadeDistance,float freezeTime,float freezePercent
	private static final Weapon ICE_TOWER_WEAPON = new FreezeGun(4,0,400,4,50,2,0.5f);
	private static final String ICE_TOWER_DESCRIPTION = "This tower will slow your enemies.";
	private static final float ICE_TOWER_RADIUS = 50;
	private static final float ICE_TOWER_COST = 100;
	
	private static Tower iceTower2;
	private static TowerInfo iceTower2Info;
	private static Image iceTower2Image;
	//float fireRate, float damage, float bulletSpeed, float numBullets,float fadeDistance,float freezeTime,float freezePercent
	private static final Weapon ICE_TOWER2_WEAPON = new FreezeGun(4,0,400,8,75,4,0.5f);
	private static final String ICE_TOWER2_DESCRIPTION = "Makes the tower freeze more enemies for a longer period of time.";
	private static final float ICE_TOWER2_RADIUS = 75;
	private static final float ICE_TOWER2_COST = 200;
	private static void intializeIceTowerSeries() throws SlickException {
		iceTowerImage = new Image("IceTower.png");
		iceTower2Image = iceTowerImage.copy();
		
		iceTowerInfo = new TowerInfo(iceTowerImage.copy(),ICE_TOWER_DESCRIPTION,ICE_TOWER_RADIUS,ICE_TOWER_COST,Config.hudFont);
		iceTower2Info = new TowerInfo(iceTower2Image.copy(),ICE_TOWER2_DESCRIPTION,ICE_TOWER2_RADIUS,ICE_TOWER2_COST,Config.hudFont);
		
		
		iceTower = new Tower(iceTowerImage.copy(),zeroVector.copy(),ICE_TOWER_WEAPON,ICE_TOWER_RADIUS,iceTower2Info);
		iceTower.remove();
	    towerInfoMap.put(iceTowerInfo, iceTower);
	    basicTowers.add(iceTowerInfo);
	    
	    iceTower2 = new Tower(iceTower2Image.copy(),zeroVector.copy(),ICE_TOWER2_WEAPON,ICE_TOWER2_RADIUS,null);
	    iceTower2.remove();
	    towerInfoMap.put(iceTower2Info, iceTower2);
	}

	private static Tower basicTower;
	private static TowerInfo basicTowerInfo;
	public static Image basicTowerImage;
	//float fireRate, float damage, float bulletSpeed for pistol Constructor
	private static final Weapon BASIC_TOWER_WEAPON = new Pistol(1,1,400);
	private static final String BASIC_TOWER_DESCRIPTION = "This is a basic tower, ready to defend your eggs.";
	private static final float BASIC_TOWER_RADIUS = 100;
	private static final float BASIC_TOWER_COST = 200;
	
	private static Tower basicTower2;
	private static TowerInfo basicTower2Info;
	public static Image basicTower2Image;
	private static final Weapon BASIC_TOWER2_WEAPON = new Pistol(2.3f,1,400);
	private static final String BASIC_TOWER2_DESCRIPTION = "Increases the towers range and rate of fire.";
	private static final float BASIC_TOWER2_RADIUS = 175;
	private static final float BASIC_TOWER2_COST = 150;
	
	private static void intializeBasicTowerSeries() throws SlickException {
		basicTowerImage = new Image("StandardTower.png");
		basicTower2Image = basicTowerImage.copy();
		
		basicTowerInfo = new TowerInfo(basicTowerImage.copy(),BASIC_TOWER_DESCRIPTION,BASIC_TOWER_RADIUS,BASIC_TOWER_COST,Config.hudFont);
		basicTower2Info = new TowerInfo(basicTower2Image.copy(),BASIC_TOWER2_DESCRIPTION,BASIC_TOWER2_RADIUS,BASIC_TOWER2_COST,Config.hudFont);
		
		
		basicTower = new Tower(basicTowerImage.copy(),zeroVector.copy(),BASIC_TOWER_WEAPON,BASIC_TOWER_RADIUS,basicTower2Info);
		basicTower.remove();
		towerInfoMap.put(basicTowerInfo, basicTower);
		basicTowers.add(basicTowerInfo);
		
		basicTower2 = new Tower(basicTower2Image.copy(),zeroVector.copy(),BASIC_TOWER2_WEAPON,BASIC_TOWER2_RADIUS,null);
		basicTower2.remove();
		towerInfoMap.put(basicTower2Info, basicTower2);
	}
}
